<template>
	<div @click.stop="onClickHandler()" :style="componentModel.cssStyle"
		:class="[selected ?'row-selected-state ': 'row-normal-state ']" style="position: relative;">
		<i class="el-icon-rank drag-widget" style="position: absolute;left: 0px;top:0px;z-index: 100;" v-show="selected"></i>
		<my-page-component ref="pageComponent"></my-page-component>
	</div>
</template>

<script>
	import utils from '@/utils/utils.js';
	import formDesignerUtil from '@/utils/formDesignerUtil.js';
	export default {
		name: "DesignDashboardPageComponent",
		props: [
			"componentModel"
		],
		data() {
			return {
				selected: false,
				"propertySet": [{
					"key": "ID",
					"label": "ID",
					"editor": "label"
				}, {
					"key": "refPageCode",
					"label": "引用页",
					"editor": "text",
				}, {
					"key": "cssStyleExpression",
					"label": "cssStyle",
					"editor": "textarea",
				}],
			}
		},
		inject: ['children'],
		mounted() {
			this.children.push(this);
		},beforeUnmount() {
			utils.removeArrayElement(this.children,this);
		},
		methods: {
			onClickHandler() {
				formDesignerUtil.componentClickHandler(this);
			},
			setSelected(selected) {
				this.selected = selected;
			},
			getPropertyValue(propertyKey) {
				if (propertyKey == "ID") {
					return formDesignerUtil.getComponentModelPropValue(this.componentModel,"id");
				} else if (propertyKey == "cssStyleExpression") {
					return formDesignerUtil.getComponentModelPropValue(this.componentModel,"cssStyle");
				} else if (propertyKey == "refPageCode") {
					return formDesignerUtil.getComponentModelPropValue(this.componentModel,"refPageCode");
				}
				return formDesignerUtil.getComponentModelCommonValue(this.componentModel,propertyKey);
			},
			setPropertyValue(propertyKey, propertyValue) {
				formDesignerUtil.setComponentModelCommonValue(this.componentModel,propertyKey, propertyValue);
				if (propertyKey == "cssStyleExpression") {
					formDesignerUtil.setComponentModelPropValue(this.componentModel,"cssStyle",propertyValue);
				} else if (propertyKey == "refPageCode") {
					formDesignerUtil.setComponentModelPropValue(this.componentModel,"refPageCode",propertyValue);
					this.$refs.pageComponent.navigatePage(propertyValue, {},true);
				}
			}
		}
	}
</script>

<style>

</style>
